package com.manager.cms.service.impl;

import com.github.pagehelper.PageHelper;
import com.manager.cms.bo.UserRole;
import com.manager.cms.common.Pageable;
import com.manager.cms.mapper.UserRoleMapper;
import com.manager.cms.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * @author 
 * @version v1.0
 * @date 2020-05-20
 */
@Service
public class UserRoleServiceImpl implements UserRoleService {

    @Autowired
    private UserRoleMapper userRoleMapper;

    @Override
    public void insert(UserRole record) {
        userRoleMapper.insert(record);
    }

    @Override
    public void update(UserRole record){
        userRoleMapper.update(record);
    }

    @Override
    public void del(String id){
        userRoleMapper.del(id);
    }

    @Override
    public UserRole selectByPrimaryKey(String id){
        return userRoleMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<UserRole> getList(UserRole record){
        return userRoleMapper.selectByRecord(record);
    }

    @Override
    public Pageable<UserRole> pageList(UserRole record, Integer pageNum, Integer pageSize){
        Integer count = userRoleMapper.countByRecord(record);
        PageHelper.startPage(pageNum, pageSize);
        List<UserRole> list = userRoleMapper.selectByRecord(record);
        return new Pageable<>(list, count, pageSize, pageNum);
    }

}